package com.itheima.reflectlearn;
/*
反编译一个类的Constructor构造方法
 */
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

public class ReflectTest11 {
    public static void main(String[] args) throws Exception{
        StringBuilder sb = new StringBuilder();

        Class vipClass = Class.forName("com.itheima.reflectlearn.Vip");
        sb.append(Modifier.toString(vipClass.getModifiers())+" class "+vipClass.getSimpleName());
        sb.append("{\n");

        Constructor[] constructors = vipClass.getConstructors();

        for(Constructor constructor:constructors){
            sb.append("\t");
            sb.append(Modifier.toString(constructor.getModifiers())+" "+vipClass.getSimpleName());
            sb.append("(");
            Class[] parameterTypes = constructor.getParameterTypes();
            for(Class parameterType:parameterTypes){
                sb.append(parameterType.getSimpleName()+",");
            }
            if(parameterTypes.length>0)sb.deleteCharAt(sb.length()-1);//删掉多余的“，"
            sb.append(");\n");
        }
        sb.append("}");


        System.out.println(sb);


    }
}
